#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>

#include <QMainWindow>
#include <QMediaPlayer>
#include <QTimer>
#include <QVector>
#include <QTime>
#include <QDate>
#include <QSystemTrayIcon>
#include <QCloseEvent>
#include <QStandardItemModel>
#include <QSettings>

namespace Ui {
    class Widget;
}

struct BellEvent{
    QTime time;
    bool enabled;
    bool operator<(const BellEvent& o)const;
    bool operator<(const QTime& o)const;
};

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = nullptr);
    ~Widget();

private:
    Ui::Widget *ui;

public:
    bool mediaSet = 0;

    QMediaPlayer *player;
    QString mediaName;
    QTimer *timer;
    QStandardItemModel *model;
    QVector<BellEvent> events;
    QSettings* settings;

    QSystemTrayIcon *tray;
protected:
    void closeEvent(QCloseEvent *event);

private:
    void initTray();
    void initUI();
    void restoreSettings();
    void saveEvents();
    QTime getTime();

public:
    void trayIconAction(QSystemTrayIcon::ActivationReason reason);
    void ringBell();
    void testTime();

public slots:
    void onLoadMedia();
    void onAddEvent();
    void onRemoveEvent();
    void onDisableEvent();
};

#endif // WIDGET_H
